package com.management.dao;

import com.management.controller.form.AllStateCountForm;
import com.management.controller.form.GetRecordsPageForm;
import com.management.controller.form.GetSeverityCountForm;
import com.management.controller.form.GetStateCountForm;
import com.management.controller.info.GetSeverityCountInfo;
import com.management.controller.info.GetTypeCountInfo;
import com.management.model.DefectRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 龙世超
 * @since 2022-03-23
 */
public interface DefectRecordDao extends BaseMapper<DefectRecord> {

    GetRecordsPageForm selectDefectRecords(GetRecordsPageForm getRecordsPageForm);

    @Select("SELECT issue_state,COUNT(*) count FROM dm_defect_record GROUP BY issue_state")
    List<AllStateCountForm> findAllStateCount();

    List<AllStateCountForm> getStateCount(GetStateCountForm getStateCountForm);

    @Select("SELECT defect_type name,COUNT(*) value FROM dm_defect_record GROUP BY defect_type")
    List<GetTypeCountInfo> getAllTypeCount();

    List<GetTypeCountInfo> getTypeCount(GetStateCountForm getStateCountForm);

    @Select("SELECT \n" +
            "defect_sevsrity name,COUNT(*) value\n" +
            "FROM dm_defect_record GROUP BY defect_sevsrity")
    List<GetSeverityCountInfo> getAllSeverityCount();

    List<GetSeverityCountInfo> getSeverityCount(GetSeverityCountForm getSeverityCountForm);
}
